package com.ruoyi.web.controller.newTable;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.THeadCx;
import com.ruoyi.system.service.ITHeadCxService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 牵头建设的国家重大科技创新基地 Controller
 * 
 * @author ruoyi
 * @date 2024-12-06
 */
@RestController
@RequestMapping("/system/cx")
public class THeadCxController extends BaseController
{
    @Autowired
    private ITHeadCxService tHeadCxService;

    /**
     * 查询牵头建设的国家重大科技创新基地 列表
     */
    @PreAuthorize("@ss.hasPermi('system:cx:list')")
    @GetMapping("/list")
    public TableDataInfo list(THeadCx tHeadCx)
    {
        startPage();
        List<THeadCx> list = tHeadCxService.selectTHeadCxList(tHeadCx);
        return getDataTable(list);
    }

    /**
     * 导出牵头建设的国家重大科技创新基地 列表
     */
    @PreAuthorize("@ss.hasPermi('system:cx:export')")
    @Log(title = "牵头建设的国家重大科技创新基地 ", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, THeadCx tHeadCx)
    {
        List<THeadCx> list = tHeadCxService.selectTHeadCxList(tHeadCx);
        ExcelUtil<THeadCx> util = new ExcelUtil<THeadCx>(THeadCx.class);
        util.exportExcel(response, list, "牵头建设的国家重大科技创新基地 数据");
    }

    /**
     * 获取牵头建设的国家重大科技创新基地 详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:cx:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tHeadCxService.selectTHeadCxById(id));
    }

    /**
     * 新增牵头建设的国家重大科技创新基地 
     */
    @PreAuthorize("@ss.hasPermi('system:cx:add')")
    @Log(title = "牵头建设的国家重大科技创新基地 ", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody THeadCx tHeadCx)
    {
        return toAjax(tHeadCxService.insertTHeadCx(tHeadCx));
    }

    /**
     * 修改牵头建设的国家重大科技创新基地 
     */
    @PreAuthorize("@ss.hasPermi('system:cx:edit')")
    @Log(title = "牵头建设的国家重大科技创新基地 ", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody THeadCx tHeadCx)
    {
        return toAjax(tHeadCxService.updateTHeadCx(tHeadCx));
    }

    /**
     * 删除牵头建设的国家重大科技创新基地 
     */
    @PreAuthorize("@ss.hasPermi('system:cx:remove')")
    @Log(title = "牵头建设的国家重大科技创新基地 ", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tHeadCxService.deleteTHeadCxByIds(ids));
    }
}
